#include <stdio.h>
#include <stdlib.h>
#include "pcb.h"



typedef PCB* ElemType;

typedef struct list_node
{
  ElemType data;
  struct list_node *prev,*next;
}list_node,list;



/*init an empty cyclic doubly linked list with header*/
list*  list_init();	
/*destory list*/				
void list_destroy(list *L);
/*get number of nodes(without header) in list*/
int list_length(list *L);
/*if the list is empty*/
int list_empty(list *L);

/*get the pointer of the node in pos,pos at least 1*/
list* list_get_pointer(list *L,int pos);
/*get the element of the node in pos,pos at least 1**/
ElemType list_get_element(list *L,int pos);
/*get the postion of given node*/
int list_get_index( list *L, list_node* pnode );

/*insert a node after the node in pos-1,the node's data is e */
int list_insert(list *L,int pos,ElemType e);
/*add a node at the end of list*/
int list_append(list *L,ElemType e);
/*remove node in pos*/
int list_remove(list *L,int pos);

/*for STCP*/
/*get the sort key*/
int list_sort_key(list_node* pnode);
/*swap two nodes,by unlikn and relink*/
void list_swap_nodes( list_node* low, list_node* high );

/*just swap the data of nodes*/
void list_swap_nodes_simple( list_node* low, list_node* high );
/*the most simple sort*/
void list_sort_simple( list *L);

/*print list*/
void list_print(list* L);

